﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="CodeGenerationPipelineInterface"
    targetNamespace="http://www.mindchemistry.com/Schemas/CodeGenerationPipelineInterface.xsd"
    elementFormDefault="qualified"
    xmlns="http://www.mindchemistry.com/Schemas/CodeGenerationPipelineInterface.xsd"
    xmlns:mstns="http://www.mindchemistry.com/Schemas/CodeGenerationPipelineInterface.xsd"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
  
  <xs:annotation>
    <xs:documentation>
      The parent child nature as described in this document does not necessarily reflect the parent-child nature of AbstraX
      parent children.  This document describes the inclusion of elements, attributes, and operations in the ElementBuild
    </xs:documentation>
  </xs:annotation>

  <xs:element name="WSDLRootMappedTo">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:pattern value="wsdl:definitions/wsdl:portType\[@name='\w+?'\]"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>

  <xs:element name="WSDLOperationMappedTo">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:pattern value="wsdl:definitions/wsdl:portType\[@name='\w+?'\](/wsdl:operation\[@name='\w+?'\])*"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  
  <xs:element name="WSDLTypeMappedTo">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:pattern value="wsdl:definitions/wsdl:types/xs:schema/xs:complexType\[@name='\w+?'\](/xs:sequence/xs:element\[@name='\w+?'\])*"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>

  <xs:element name="InternalMappedTo">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:pattern value="pipeline:ElementBuild/pipeline:Elements\[@name='\w+?'\](/pipeline:Element\[@name='\w+?'\])*"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  
  <xs:element name="Element">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="WSDLTypeMappedTo" maxOccurs="1" />
        <xs:element name="ChildElements" maxOccurs="1" minOccurs="0">
          <xs:complexType>
            <xs:sequence>
              <xs:element ref="Element" maxOccurs="unbounded" minOccurs="0" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="Attributes" maxOccurs="1" minOccurs="0">
          <xs:complexType>
            <xs:sequence>
              <xs:element ref="Attribute" maxOccurs="unbounded" minOccurs="0" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="Operations" maxOccurs="1" minOccurs="0">
          <xs:complexType>
            <xs:sequence>
              <xs:element ref="Operation" maxOccurs="unbounded" minOccurs="0" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
      <xs:attribute name="Name" type="xs:string" use="required" />
    </xs:complexType>
  </xs:element>

  <xs:element name="Attribute">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="WSDLTypeMappedTo" maxOccurs="1" />
        <xs:element name="ChildElements" maxOccurs="1" minOccurs="0">
          <xs:complexType>
            <xs:sequence>
              <xs:element ref="Element" maxOccurs="unbounded" minOccurs="0" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
      <xs:attribute name="Name" type="xs:string" use="required" />
    </xs:complexType>
  </xs:element>

  <xs:element name="Operation">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="WSDLOperationMappedTo" maxOccurs="1" />
        <xs:element ref="TypeArguments" maxOccurs="1" minOccurs="0" />
        <xs:element ref="Arguments" maxOccurs="1" minOccurs="0" />
        <xs:element name="DataContextOperation" maxOccurs="1" minOccurs="1">
          <xs:complexType>
            <xs:choice>
              <xs:element ref="OptionalDataContextOperation" />
              <xs:element ref="DefaultDataContextOperation" />
            </xs:choice>
          </xs:complexType>
        </xs:element>
        <xs:element name="Initialization" maxOccurs="1" minOccurs="0">
          <xs:complexType>
            <xs:all>
              <xs:element ref="Instantiate" minOccurs="0" />
              <xs:element ref="Declare" minOccurs="0" />
            </xs:all>
          </xs:complexType>
        </xs:element>
        <xs:element name="PostProcessing" maxOccurs="1" minOccurs="0">
          <xs:complexType>
            <xs:all>
              <xs:element ref="Instantiate" minOccurs="0" />
              <xs:element ref="Declare" minOccurs="0" />
            </xs:all>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
      <xs:attribute name="Name" type="xs:string" use="required" />
    </xs:complexType>
  </xs:element>  
    
  <xs:element name="Source">
    <xs:complexType>
        <xs:choice>
          <xs:element ref="WSDLTypeMappedTo" maxOccurs="1" />
          <xs:element ref="InternalMappedTo" maxOccurs="1" />
          <xs:element name="Value" type="xs:string" maxOccurs="1" />
        </xs:choice>
    </xs:complexType>
  </xs:element>

  <xs:element name="Assign">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Left" maxOccurs="1" minOccurs="1">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Property" type="xs:string" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>  
        <xs:element name="Right" maxOccurs="1" minOccurs="1">
          <xs:complexType>
            <xs:sequence>
              <xs:element ref="Source" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="TypeArguments">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Source" maxOccurs="unbounded" minOccurs="0" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="Arguments">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Source" maxOccurs="unbounded" minOccurs="0" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="Assignments">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Assign" maxOccurs="unbounded" minOccurs="0" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="Instantiate">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="WSDLTypeMappedTo" maxOccurs="1" />
        <xs:element ref="TypeArguments" maxOccurs="1" minOccurs="1" />
        <xs:element ref="Arguments" maxOccurs="1" minOccurs="1" />
        <xs:element ref="Assignments" maxOccurs="1" minOccurs="1" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="Declare">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="WSDLTypeMappedTo" maxOccurs="1" />
        <xs:element name="TypeArguments" maxOccurs="1" minOccurs="1">
          <xs:complexType>
            <xs:sequence>
              <xs:element ref="Source" maxOccurs="unbounded" minOccurs="0" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="Assignments" maxOccurs="1" minOccurs="1">
          <xs:complexType>
            <xs:sequence>
              <xs:element ref="Assign" maxOccurs="unbounded" minOccurs="0" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="OptionalDataContextOperation">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="Insert"/>
        <xs:enumeration value="Update"/>
        <xs:enumeration value="Delete"/>
        <xs:enumeration value="Search"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>

  <xs:element name="DefaultDataContextOperation">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="GetAll"/>
        <xs:enumeration value="GetByID"/>
        <xs:enumeration value="GetChildrenForParent"/>
        <xs:enumeration value="GetCountOfChildrenForParent"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>

  <xs:element name="BuildAction">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="BuildActionNone"/>
        <xs:enumeration value="BuildActionCompile"/>
        <xs:enumeration value="BuildActionContent"/>
        <xs:enumeration value="BuildActionEmbeddedResource"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>

  <xs:element name="CopyToOutputDirectory">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="DoNotCopy"/>
        <xs:enumeration value="CopyAlways"/>
        <xs:enumeration value="CopyIfNewer"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>

  <xs:element name="ElementBuild">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Requirements" maxOccurs="1" minOccurs="1">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="IncludeFiles" maxOccurs="1" minOccurs="1">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="File" maxOccurs="unbounded" minOccurs="0">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element ref="BuildAction" maxOccurs="1" minOccurs="1"/>
                          <xs:element name="Type" type="xs:string" maxOccurs="1" minOccurs="1" />
                          <xs:element name="SourcePath" type="xs:string" maxOccurs="1" minOccurs="1" />
                          <xs:element name="SuggestedTargetRelativePath" type="xs:string"  maxOccurs="1" minOccurs="1" />
                          <xs:element name="CustomTool" type="xs:string" maxOccurs="1" minOccurs="1" />
                          <xs:element name="CustomNamespace" type="xs:string" maxOccurs="1" minOccurs="1" />
                          <xs:element ref="CopyToOutputDirectory" maxOccurs="1" minOccurs="1"/>
                        </xs:sequence>
                        <xs:attribute name="MergeWithExisting" type="xs:boolean" use="required" />
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="RequiredPackages" maxOccurs="1" minOccurs="1">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="Package" maxOccurs="unbounded" minOccurs="0">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="Name" type="xs:string" maxOccurs="1" minOccurs="1" />
                          <xs:element name="Path" type="xs:string" maxOccurs="1" minOccurs="1" />
                          <xs:element name="Type" type="xs:string" maxOccurs="1" minOccurs="1" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="RequiredImports" maxOccurs="1" minOccurs="1">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="Import" maxOccurs="unbounded" minOccurs="0">
                      <xs:complexType>
                        <xs:attribute name="Name" type="xs:string" use="required" />
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="RequiredConfiguration" maxOccurs="1" minOccurs="1">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="Configuration" maxOccurs="unbounded" minOccurs="0">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="Location" maxOccurs="unbounded" minOccurs="1">
                            <xs:simpleType>
                              <xs:restriction base="xs:string">
                                <xs:pattern value="configuration(/[\w\.]+?(\[@\w+?='\w+?'\])*)*"/>
                              </xs:restriction>
                            </xs:simpleType>
                          </xs:element>
                          <xs:element name="ConfigurationData" maxOccurs="1" minOccurs="1" type="xs:normalizedString" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="Elements" maxOccurs="1" minOccurs="1">
          <xs:complexType>
             <xs:sequence>
              <xs:element name="Root" maxOccurs="1" minOccurs="1">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element ref="WSDLRootMappedTo" minOccurs="1" maxOccurs="1" />
                    <xs:element ref="TypeArguments" minOccurs="0" maxOccurs="1" />
                    <xs:element ref="Arguments" minOccurs="0" maxOccurs="1" />
                    <xs:element name="ChildElements" maxOccurs="1" minOccurs="0">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element ref="Element" maxOccurs="unbounded" minOccurs="0" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                  <xs:attribute name="Name" type="xs:string" use="required" />
                </xs:complexType>
              </xs:element>
             </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

</xs:schema>
